<script>
import axios from "axios";
import ModifyData from "@/components/dialog/ModifyData.vue";
import HomePhoto from "@/components/view/littleview/HomePhoto.vue";
import HomeDynamic from "@/components/view/littleview/HomeDynamic.vue";
import HomeMessage from "@/components/view/littleview/HomeMessage.vue";
import HomeMusic from "@/components/view/littleview/HomeMusic.vue";

export default {
  name: "HomeView",
  components: {HomeMusic, HomeMessage, HomeDynamic, HomePhoto, ModifyData},
  data() {
    return {
      test: '',
      fans: "",
      follow: "",
      modify_data: false,
      menu:1
    }
  },
  methods: {
    showBigPic(e) {
      let big = document.getElementsByClassName('big_pic')[0]
      big.parentNode.style.display = 'flex'
      big.src = e.target.src
    },
    exitBigPic(e) {
      let div = e.target
      if (div.tagName === 'IMG')
        div = div.parentNode
      div.style.display = 'none'
    },
  },
  mounted() {
    axios.get("/api/friends/fans")
        .then(res => this.fans = res.data)
        .catch(() => this.fans = 0)
    axios.get("/api/friends/follow")
        .then(res => this.follow = res.data)
        .catch(() => this.follow = 0)
  }
}
</script>

<template>
  <div class="cont_box">

    <el-dialog :visible.sync="modify_data" title="编辑个人资料" top="8vh" width="25%" center append-to-body>
      <modify-data></modify-data>
    </el-dialog>
    <div class="cont_top_hm">
      <div class="zl_box">
        <div class="zl_top">
          <el-avatar :src="$store.state.user.avatar"></el-avatar>
          <div class="zl_text">
            <div class="zl_nick">{{ $store.state.user.nickname }}<i
                :class="$store.state.user.gender==='男'?'el-icon-male':'el-icon-female'"></i></div>
            <div class="zl_hy">
              粉丝: <span style="color: black;margin-right: 10px">{{ fans }}</span>
              关注: <span style="color: black">{{ follow }}</span>
            </div>
          </div>
        </div>
        <div class="zl_bottom">
          <div style="float: left;margin-right: 6px"><i class="el-icon-edit-outline"></i>个性签名:</div>
          {{ $store.state.user.signature }}

          <div class="bj_zl" @click="modify_data=true"> 编辑资料</div>
        </div>

      </div>
    </div>

    <el-row class="tac" style="background-color:#ffffff;margin-top: 10px; border-radius: 5px">
      <el-col :span="3">
        <h3 style="margin-left: 25px">个人主页</h3>
        <el-menu
            default-active="1">
          <el-menu-item index="1" class="my_icon" @click.native="menu=1">
            <i class="iconfont icon-xiangce"></i>
            <span slot="title">个人相册</span>
          </el-menu-item>
          <el-menu-item index="2" class="my_icon" @click.native="menu=2">
            <i class="iconfont icon-fenxiang"></i>
            <span slot="title">个人动态</span>
          </el-menu-item>
          <el-menu-item index="3" @click.native="menu=3">
            <i class="el-icon-document"></i>
            <span slot="title">留言板</span>
          </el-menu-item>
          <el-menu-item index="4" @click.native="menu=4">
            <i class="el-icon-headset"></i>
            <span slot="title">音乐</span>
          </el-menu-item>
        </el-menu>
      </el-col>
      <el-col :span="21">
        <div class="zy_cont">
          <home-photo v-if="menu===1"></home-photo>
          <home-dynamic v-else-if="menu===2"></home-dynamic>
          <home-message v-else-if="menu===3"></home-message>
          <home-music v-else-if="menu===4"></home-music>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<style>
.cont_top_hm {
  display: flex;
  width: 100%;
  border-radius: 5px;
  padding-top: 18px;
  padding-bottom: 15px;
  background-color: #ffffff;
  flex-direction: column;

  .el-icon-zoom-in:hover {
    color: #409EFF;
  }

  .el-icon-delete:hover {
    color: #f44336;
  }
}

.zl_box {
  width: 90%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.zl_top {
  .el-avatar {
    height: 80px;
    width: 80px;
    float: left;
  }
}

.zl_text {
  float: left;
  height: 80px;
  margin-left: 20px;
}

.zl_nick {
  height: 60px;
  font-size: 25px;
  line-height: 60px;
  color: black;
  font-weight: bold;


}

.zl_nick i {
  margin-left: 5px;
}

.zl_hy {
  color: #7e8a8c;
  height: 20px;
}

.zl_bottom {
  margin-top: 10px;
  color: #7e8a8c;
  margin-left: 100px;
}

.zl_bottom i {
  margin-right: 3px;
}

.bj_zl {
  float: right;
  margin-right: 20px;
  cursor: pointer;
}

.bj_zl:hover {
  color: #409EFF;
}

.my_icon i{
  margin-left: 5px;
  margin-right: 5px;
  width: 24px;
  text-align: center;
}

.zy_cont{
  height: 410px;
  padding: 5px 0;
  overflow: auto;
}
</style>